/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityBeans;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

/**
 *
 * @author h09577
 */
@NamedQueries({
    @NamedQuery(name = "UserEntity.getUsers", query = "SELECT u "
    + "FROM UserEntity u "
    + "WHERE u.email=:email AND u.password=:password"),
    @NamedQuery(name = "UserEntity.checkEmail", query = "SELECT u "
    + "FROM UserEntity u "
    + "WHERE u.email=:email"),
    @NamedQuery(name = "UserEntity.checkPseudo", query = "SELECT u "
    + "FROM UserEntity u "
    + "WHERE u.pseudo=:pseudo"),
    @NamedQuery(name = "UserEntity.checkUpdatePseudo", query = "SELECT u "
    + "FROM UserEntity u "
    + "WHERE u.pseudo=:pseudo AND u.id<>:id")
})
@DiscriminatorValue("user")
@Entity
public class UserEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Basic
    private String email;
    @Basic
    private String password;
    @Basic
    private String pseudo;
    @Basic
    private String name;
    @Basic
    private String firstName;
    @Basic
    private String signature;
    @Basic
    private String status;
    @OneToMany(mappedBy = "myAuthor", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    private List<MessageEntity> myMessages;
    @OneToMany(mappedBy = "myAuthor", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    private List<ThreadEntity> myThreads;
    @OneToMany(mappedBy = "myTarget", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    private List<PrivateMessageEntity> myPrivateMessages;
    
    public String getSignature() {
        return signature;
    }

    public void setSignature(String signature) {
        this.signature = signature;
    }
    
    public List<PrivateMessageEntity> getMyPrivateMessages() {
        return myPrivateMessages;
    }

    public void setMyPrivateMessages(List<PrivateMessageEntity> myPrivateMessages) {
        this.myPrivateMessages = myPrivateMessages;
    }

    public List<MessageEntity> getMyMessages() {
        return myMessages;
    }

    public void setMyMessages(List<MessageEntity> myMessages) {
        this.myMessages = myMessages;
    }

    public List<ThreadEntity> getMyThreads() {
        return myThreads;
    }

    public void setMyThreads(List<ThreadEntity> myThreads) {
        this.myThreads = myThreads;
    }

    /**
     * Get the value of status
     *
     * @return the value of status
     */
    public String getStatus() {
        return status;
    }

    /**
     * Set the value of status
     *
     * @param status new value of status
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * Get the value of firstName
     *
     * @return the value of firstName
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * Set the value of firstName
     *
     * @param firstName new value of firstName
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
     * Get the value of name
     *
     * @return the value of name
     */
    public String getName() {
        return name;
    }

    /**
     * Set the value of name
     *
     * @param name new value of name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Get the value of pseudo
     *
     * @return the value of pseudo
     */
    public String getPseudo() {
        return pseudo;
    }

    /**
     * Set the value of pseudo
     *
     * @param pseudo new value of pseudo
     */
    public void setPseudo(String pseudo) {
        this.pseudo = pseudo;
    }

    /**
     * Get the value of password
     *
     * @return the value of password
     */
    public String getPassword() {
        return password;
    }

    /**
     * Set the value of password
     *
     * @param password new value of password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Get the value of email
     *
     * @return the value of email
     */
    public String getEmail() {
        return email;
    }

    /**
     * Set the value of email
     *
     * @param email new value of email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserEntity)) {
            return false;
        }
        UserEntity other = (UserEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityBeans.UserEntity[ id=" + id + " ]";
    }
}
